<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let age = 22;
        console.log(typeof age);//数据类型为 number


        //1.number转化为字符串
        age = age.toString();
        console.log(typeof age);//number转化数据类型为string

        //2.强制转化
        console.log('--------强制转化-------');
        //1.
        let age1 = String(22)
        console.log(typeof age1);
        //2.
        let score = String(100);
        console.log(typeof score);//string


        //3. prompt ()接收的数据作为字符串
        let year = prompt('请输入你的出生年');
        console.log(typeof year);//string




    </script>

</body>

</html>